package com.awt.topic1;

import java.applet.Applet;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * @ClassName: StarterCombined
 * @Author: ZhangYue26
 * @Description:
 * @Date: 2020-11-06
 */
public class StarterCombined extends Applet {
    private Label label;

    public static void main(String[] args) {
        StarterCombinedFrame starter_application = new StarterCombinedFrame("Starter Application");
        starter_application.setSize(300, 100);
        starter_application.show();
        System.out.println("StarterCombinedFrame::main()");
    }

    @Override
    public void init(){
        System.out.println("Applet::init()");
    }

    @Override
    public void stop() {
        System.out.println("Applet::stop()");
        remove(label);
    }
    public void destroy(){
        System.out.println("Applet::destroy()");
    }

    public static class StarterCombinedFrame extends Frame {
        public StarterCombinedFrame(String frameTitle) {
            super(frameTitle);
            StarterCombined applet = new StarterCombined();
            applet.start();
            add(applet, "Center");
            addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosing(WindowEvent e) {
                    dispose();
                    System.exit(0);
                }
            });
        }
    }

}
